<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Set" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/custom.css">
    <title>部门</title>

</head>
<body>
<%@include file="header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@include file="nav.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">全部部门</h2>
            </div>
        </div>
        <section class="no-padding-bottom">
            <%
                List<Map<Object, ArrayList<Object>>> dept = (List<Map<Object, ArrayList<Object>>>) request.getAttribute("dept");
                Set<Object> keySet = dept.get(0).keySet();
                request.setAttribute("key", keySet);
                int i = 0;
                ArrayList<Object> objects = new ArrayList<>();
                for (Object o : keySet) {
                    objects.add(o);
                    System.out.println(o);
                }
            %>
            <div class="list-group subject">
                <c:forEach items="${key}" var="k">
                    <div class="list-group-item">
                        <a href="#deptDetail<%=i+1%>" data-toggle="collapse">${k} &nbsp;<%
                            int size = dept.get(0).get(objects.get(i)).size();
                %><%=size%>人</a>
                        <div id="deptDetail<%=i+1%>" class="collapse deptDetail">
                            <ul>
                                <%
                                    ArrayList<Object> list = dept.get(0).get(objects.get(i));
                                    request.setAttribute("list",list);
                                    i++;
                                %>
                                <c:forEach items="${list}" var="name">
                                    <li>
                                        <a href="#">${name}</a>
                                    </li>
                                </c:forEach>
                            </ul>
                        </div>
                    </div>
                </c:forEach>

            </div>
        </section>

       <%@include file="footer.jsp"%>
    </div>
</div>

<!-- JavaScript files-->
<%@include file="floor.jsp"%>
</body>
</html>